package edu.spbsu.nonsm00th.model;

import edu.spbsu.nonsm00th.util.Precondition;
import java.util.Arrays;

/**
 *
 * @author mbuzdov
 */
@Deprecated
public class DN {

    private double x[];
    private int N;

    public DN(double x[]) {
        this.N = x.length;
        this.x = x;
    }
    public DN(int N) {
        this.N = N;
        this.x = new double[N];
        for (int i = 0; i < N; i++) {
            this.x[i] = 0.0;
        }
    }

    public double[] getX() {
        return x;
    }
    public void setX(double[] values) {
        Precondition.argsNotNull(values);
        Precondition.check(N == values.length, "Array of values must have size " + N);
        this.x = values;
    }
    public double getXi(int i) {
        Precondition.check(i < N, "Index must be less than " + N);
        return x[i];
    }
    public void setXi(int i, double value) {
        Precondition.check(i < N, "Index must be less than " + N);
        this.x[i] = value;
    }
    public int getN() {
        return N;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof DN) {
            final DN to = (DN) obj;
            if (to.N != this.N) {
                return false;
            }
            for (int i = 0; i < to.N; i++) {
                if (to.x[i] != this.x[i]) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 47 * hash + Arrays.hashCode(this.x);
        hash = 47 * hash + this.N;
        return hash;
    }

}
